
package socketsudp;

import java.io.Console;
import java.net.DatagramSocket;
import java.net.SocketException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author epulapp
 */
public class UDPPortScanner {
    
    private Boolean[] tDS;

    public UDPPortScanner() {
        tDS = new Boolean[65535];
        scan();
    }
    
    public void scan() {
        for (int i = 0; i < 65535; i++) {
            try {
                DatagramSocket s = new DatagramSocket(i); //Peut générer l'exception
                tDS[i] = true;
            } catch (SocketException ex) {
                tDS[i] = false;
                System.out.println("Port " + i + " indisponible");
            }
        }
    }
    
    public Boolean isDispo(int port) {
        return tDS[port];
    }
    
}
